package
{

	public class ViewData
	{
		public var isAdd_view : Boolean = false;
		public var index : int;
		/**
		 * 类名
		 */
		public var filed_type : String;
		/**
		 * 皮肤中的名字
		 */
		public var skin_name : String;
		/**
		 * 元件名
		 */
		public var field_name : String;
		/**
		 * 所有包名
		 */
		public var package_names : Array = [];
		/**
		 * 替换参数名字
		 */
		public var replace_name : String;
		/**
		 * 构建类的参数
		 */
		public var view_params : Array;
		/**
		 * 元件自己是否作为参数
		 */
		public var view_is_param : Boolean;
		/**
		 * 是否移除原先元件
		 */
		public var remove_view : Boolean;
		/**
		 * 是否添加坐标
		 */
		public var view_position : Boolean;
		/**
		 * 参数是否数组
		 */
		public var param_is_array : Boolean;

		public var isSkin : Boolean = false;

		public function ViewData()
		{
		}

		public function addParam(params : *) : void
		{
			if(view_params == null)
			{
				view_params = [];
			}

			if(params is Array)
			{
				view_params = view_params.concat(params);

				var len : int = params.length;

				for(var i : int = 0; i < len; i++)
				{
					var param : String = params[i];

					if(param.indexOf("点") == -1)
						continue;
					param = txtReplce(param);

					if(package_names.indexOf(param) == -1)
					{
						package_names.push(param);
						var tmpArr : Array = param.split(".");
						view_params[i] = tmpArr[tmpArr.length - 1];
					}
				}
			}
			else
			{
				view_params.push(params);
			}
		}

		public function txtReplce(str : String) : String
		{
			if(str.indexOf("点") >= 0)
			{
				str = str.replace("点", ".");

				if(str.indexOf("点") >= 0)
				{
					return txtReplce(str);
				}
			}
			return str;
		}

		public function clone() : ViewData
		{
			var data : ViewData = new ViewData();
			data.filed_type = filed_type;
			data.field_name = field_name;
			data.replace_name = replace_name;
			data.remove_view = remove_view;
			data.view_is_param = view_is_param;
			data.view_position = view_position;
			data.param_is_array = param_is_array;
			data.isAdd_view = isAdd_view;

			if(package_names)
				data.package_names = [].concat(package_names);

			if(view_params)
				data.view_params = [].concat(view_params);
			return data;
		}
	}
}